package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.LitemallSysConfigMapper;
import org.linlinjava.litemall.db.domain.LitemallSysConfig;
import org.linlinjava.litemall.db.domain.LitemallSysConfigExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: renshuai
 * @date: 2019/3/4 15:41
 * @Description:
 */
@Service
public class LitemallSysConfigService {

    @Autowired
    private LitemallSysConfigMapper sysConfigMapper;
    public List<LitemallSysConfig> getList() {
        List<LitemallSysConfig> sysConfigs = sysConfigMapper.selectByExample(null);
        return sysConfigs;
    }

    public int updateSysConfig(LitemallSysConfig config) {
        return sysConfigMapper.updateByPrimaryKey(config);
    }

    public LitemallSysConfig getByType(int type) {
        LitemallSysConfigExample example = new LitemallSysConfigExample();
        example.createCriteria().andTypeEqualTo(type);
        return sysConfigMapper.selectByExample(example).get(0);
    }
}
